<?php
/**
 * Template Name: Add New Slot
 */
get_header(); ?>

<div class="container">
    <h1><?php the_title() ?></h1>

    <div class="row-fluid">
        <div class="span8">
            <div class="card grey clearfix">
                <form id="SlotForm" class="form-horizontal">
                    <input type="hidden" name="new_slot_form" value="true"/>

                    <div class="control-group">
                        <label class="control-label" for="Venue">Venue</label>

                        <div class="controls">
                            <select id="Venue" name="form_venue">
                                <?
                                $q = new WP_Query('post_type=venue');
                                while ($q->have_posts()) : $q->the_post();
                                    echo '<option value="' . $q->post->ID . '">' . get_field('name', $q->post->ID) . '</option>';
                                endwhile;
                                wp_reset_postdata();
                                ?>
                            </select>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="Pitch">Pitch</label>

                        <div class="controls">
                            <select id="Pitch" name="form_pitch">
                                <option>All</option>
                                <?
                                $q = new WP_Query(array('post_type' => 'pitch', 'order' => 'ASC'));
                                while ($q->have_posts()) : $q->the_post();
                                    echo '<option data-venue="' . getVenueID($q->post->ID) . '" value="' . $q->post->ID . '">' . get_field('pid') . ' - ' . get_field('name', getVenueID($q->post->ID)) . '</option>';
                                endwhile;
                                wp_reset_postdata();
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="Day">Day</label>

                        <div class="controls">
                            <select multiple id="Day" name="form_day" style="height: 140px;">
                                <option>Monday</option>
                                <option>Tuesday</option>
                                <option>Wednesday</option>
                                <option>Thursday</option>
                                <option>Friday</option>
                                <option>Saturday</option>
                                <option>Sunday</option>
                            </select>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="Intervals">Intervals</label>

                        <div class="controls">
                            <select id="Intervals" name="intervals">
                                <option value="">Single Slot</option>
                                <option value="15">15 Minutes</option>
                                <option value="30">30 Minutes</option>
                                <option value="45">45 Minutes</option>
                                <option value="60">60 Minutes</option>
                                <option value="75">75 Minutes</option>
                                <option value="90">90 Minutes</option>
                                <option value="105">105 Minutes</option>
                                <option value="120">120 Minutes</option>
                            </select>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="StartTime">Start Time</label>

                        <div class="controls">
                            <select id="StartTime" name="form_start_time">
                                <?
                                $b = 0;
                                for ($a = 9; $a < 24; $a) {

                                    echo '<option value="' . dp2($a) . dp2($b) . '">' . dp2($a) . ':' . dp2($b) . '</option>';
                                    $b += 15;
                                    if ($b == 60) {
                                        $b = 0;
                                        $a++;
                                    }
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="EndTime">End Time</label>

                        <div class="controls">
                            <select id="EndTime" name="form_end_time">
                                <?
                                $b = 15;
                                for ($a = 9; $a < 24; $a) {

                                    echo '<option value="' . dp2($a) . dp2($b) . '">' . dp2($a) . ':' . dp2($b) . '</option>';
                                    $b += 15;
                                    if ($b == 60) {
                                        $b = 0;
                                        $a++;
                                    }
                                }
                                ?>
                                <option value="2359">23:59</option>
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="Price">Price</label>

                        <div class="controls">
                            <input id="Price" name="form_price" value="45.00" type="text"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <div class="controls">
                            <input type="submit" class="btn btn-primary"/>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="span4">
            <div class="card grey">
                <div class="alert alert-success">
                    <p><strong>Slots Added Successfully</strong></p>
                    <div class=" slot-success">

                    </div>
                </div>
                <div class="alert alert-error">
                    <p><strong>Slots Failed With Conflicts</strong></p>
                    <div class=" slot-denied">

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<?php get_footer(); ?>

<script src="<?php echo get_template_directory_uri(); ?>/js/PW.addNewSlot.js"></script>
<script>

    $(function () {
        var options = {};
        PW.addNewSlot.init(options);
    });

</script>